Xbasic

FILTER_STRING Function

Syntax

Output_List as C = FILTER_STRING(C string ,C sub_string,[C delimiter[,L exclude]])

Arguments

Output_List

A character string separated into "records" by the character string Delimiter.

string

A character string to find in each "record" of the Input_List.

sub_string

Character

delimiter

A character string that separates the Input_List into multiple "records".

exclude

Logical. Optional. Default value = .F. (FALSE). .T. = The String_Array[] excludes the "records" that contain sub-string. .F. = The String_Array[] contains only the "records" that contain the Find_String.

Description

Filter in/out words that contain case insensitive sub_string from a list, default delimiter is CR-LF.

Discussion

FILTER_STRING() takes an Input_List that is divided into logical "records" by a Delimiter and either extracts or excludes the "records" that contain the Find_String characters anywhere within each "record" in the string. Case insensitive. This function is typically used in Xbasic scripts. It is extremely useful for manipulating the CR-LF delimited strings that are returned by many of the Alpha Anywhere methods (such as A5.FORM_ENUM()).

Example

String = <<%a%
Red Ball
Green Ball
Yellow Bucket
Black Hat
%a%
filter_string(string, "black", chr(13) + chr(10) ,.T.)
->   " Red Ball
Green Ball
Yellow Bucket"

This script initializes an array with the forms for the Customer table.

allforms = a5.form_enum()
filtered_forms = filter_string(allforms,"customer.ddd",chr(13) + chr(10))
dim forms200 as C
forms.initialize(filtered_forms)

See Also